#include "stdio.h"
#include "SDL/SDL.h"
#include "windows.h"
#include "time.h"
void moveball1 (int *vx,int *vy);
void moveball2 (int *vx,int *vy);
int main(int argc, char *argv[]) {
SDL_Surface *screen; //This pointer will reference the backbuffer
SDL_Surface *image1, *image7, *image13;
SDL_Surface *image2, *image8, *image14;
SDL_Surface *image3, *image9;
SDL_Surface *image4, *image10;
SDL_Surface *image5, *image11;
SDL_Surface *image6, *image12; //This pointer will reference our bitmap sprite
SDL_Surface *temp1, *temp7, *temp13;
SDL_Surface *temp2, *temp8, *temp14;
SDL_Surface *temp3, *temp9;
SDL_Surface *temp4, *temp10;
SDL_Surface *temp5, *temp11;
SDL_Surface *temp6, *temp12;
//This pointer will temporarily reference our bitmap sprite
SDL_Rect src1, src2, dest1, dest2, dest3, dest4, dest5, dest6, dest7, dest8, dest9, dest12, dest13, dest14, dest15, dest16;//These rectangles will describe the source and destination regions ofour blit
SDL_Event event;
int done = 1;
int i,x,vy=1,vx=5,s1=0,s2=0;
char pause;
//We must first initialize the SDL video component, and check for success
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
printf("Unable to initialize SDL: %s\n", SDL_GetError());
return 1;
}
//Set the video mode to fullscreen 640x480 with 16bit colour and double- buffering
screen = SDL_SetVideoMode(1100, 700, 32, SDL_HWSURFACE | SDL_DOUBLEBUF);
if (screen == NULL) {
printf("Unable to set video mode: %s\n", SDL_GetError());
return 1;
}
//Load the bitmap into a temporary surface, and check for success
temp3 = SDL_LoadBMP("img/tile.bmp");
temp1 = SDL_LoadBMP("img/table231.bmp");
temp4 = SDL_LoadBMP("img/initial.bmp");
temp2 = SDL_LoadBMP("img/ball5.bmp");
temp5 = SDL_LoadBMP("img/initial1.bmp");
temp6 = SDL_LoadBMP("img/acceil.bmp");
temp7 = SDL_LoadBMP("img/score.bmp");
temp8 = SDL_LoadBMP("img/diff.bmp");
temp9 = SDL_LoadBMP("img/aide.bmp");
temp10 = SDL_LoadBMP("img/credit.bmp");
temp11 = SDL_LoadBMP("img/pause.bmp");
temp12 = SDL_LoadBMP("img/0.bmp");
temp13 = SDL_LoadBMP("img/ball5.bmp");
temp14 = SDL_LoadBMP("img/0.bmp");
if (temp1 == NULL) {
printf("Unable to load bitmap: %s\n", SDL_GetError());
return 1;
}
if (temp2 == NULL) {
printf("Unable to load bitmap: %s\n", SDL_GetError());
return 1;
}
//Convert the surface to the appropriate display format
image1 = SDL_DisplayFormat(temp1);
image2 = SDL_DisplayFormat(temp2);
image3 = SDL_DisplayFormat(temp3);
image4 = SDL_DisplayFormat(temp4);
image5 = SDL_DisplayFormat(temp5);
image6 = SDL_DisplayFormat(temp6);
image7 = SDL_DisplayFormat(temp7);
image8 = SDL_DisplayFormat(temp8);
image9 = SDL_DisplayFormat(temp9);
image10 = SDL_DisplayFormat(temp10);
image11 = SDL_DisplayFormat(temp11);
image12 = SDL_DisplayFormat(temp12);
image13 = SDL_DisplayFormat(temp13);
image14 = SDL_DisplayFormat(temp14);
SDL_SetColorKey(image1, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image1->format, 255, 255, 255));
SDL_SetColorKey(image2, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image2->format, 255, 255, 255));
SDL_SetColorKey(image4, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image4->format, 255, 255, 255));
SDL_SetColorKey(image5, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image5->format, 255, 255, 255));
SDL_SetColorKey(image6, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image6->format, 255, 255, 255));
SDL_SetColorKey(image7, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image7->format, 255, 255, 255));
SDL_SetColorKey(image8, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image8->format, 255, 255, 255));
SDL_SetColorKey(image9, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image9->format, 255, 255, 255));
SDL_SetColorKey(image11, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image11->format, 255, 255, 255));
SDL_SetColorKey(image12, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image12->format, 255, 255, 255));
SDL_SetColorKey(image13, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image13->format, 255, 255, 255));
//Construct the source rectangle for our blit
src1.x = 0;
src1.y = 0;
src1.w = image1->w; //Use image->w to display the entire width of the image
src1.h = image1->h; //Use image->h to display the entire height of the image
//Construct the destination rectangle for our blit
dest1.x = 175;//Display the image at the (X,Y) coordinates (100,100)
dest1.y = 200;
dest1.w = image1->w;
dest1.h = image1->h;
dest2.x = 330;//Display the image at the (X,Y) coordinates (100,100)
dest2.y = 10;
dest2.w = image2->w;
dest2.h = image2->h;
dest3.x = 0;//Display the image at the (X,Y) coordinates (100,100)
dest3.y = 0;
dest3.w = image2->w;
dest3.h = image2->h;
dest4.x = 850;//Display the image at the (X,Y) coordinates (100,100)
dest4.y = 270;
dest4.w = image2->w;
dest4.h = image2->h;
dest5.x = 75;//Display the image at the (X,Y) coordinates (100,100)
dest5.y = 110;
dest5.w = image2->w;
dest5.h = image2->h;
dest6.x = 0;
dest6.y = 0;
dest6.w = image6->w;
dest6.h = image6->h;
dest7.x = 0;
dest7.y = 0;
dest7.w = image7->w;
dest7.h = image7->h;
dest8.x = 752;
dest8.y = 270;
dest8.w = image8->w;
dest8.h = image8->h;
dest9.x = 700;
dest9.y = 252;
dest9.w = image9->w;
dest9.h = image9->h;
dest12.x = 200;
dest12.y = 202;
dest12.w = image12->w;
dest12.h = image12->h;
dest13.x = 700;
dest13.y = 250;
dest13.w = image13->w;
dest13.h = image13->h;
dest14.x = 0;
dest14.y = 0;
dest14.w = image10->w;
dest14.h = image10->h;
dest15.x = 470;
dest15.y = 13;
dest15.w = image12->w;
dest15.h = image12->h;
dest16.x = 580;
dest16.y = 13;
dest16.w = image12->w;
dest16.h = image12->h;

x=0;
//Blit the image to the backbuffer
SDL_BlitSurface(image14, NULL, screen, &dest16);
SDL_BlitSurface(image11, NULL, screen, &dest7);
SDL_BlitSurface(image12, NULL, screen, &dest15);
SDL_BlitSurface(image3, NULL, screen, &dest3);
SDL_BlitSurface(image1, &src1, screen, &dest1);
SDL_BlitSurface(image2, NULL, screen, &dest2);
SDL_BlitSurface(image4, NULL, screen, &dest4);
SDL_BlitSurface(image5, NULL, screen, &dest5);
SDL_BlitSurface(image6, NULL, screen, &dest6);
SDL_BlitSurface(image7, NULL, screen, &dest7);
SDL_BlitSurface(image8, NULL, screen, &dest7);
SDL_BlitSurface(image13, NULL, screen, &dest13);
//Flip the backbuffer to the primary Hardware Video Memory
//Release the surface
//SDL_FreeSurface(image);
while(done)
{
//Blit the image to the backbuffer
SDL_BlitSurface(image11, NULL, screen, &dest7);
SDL_BlitSurface(image12, NULL, screen, &dest12);
SDL_BlitSurface(image1, &src1, screen, &dest1);
SDL_BlitSurface(image2, NULL, screen, &dest2);
SDL_BlitSurface(image4, NULL, screen, &dest4);
SDL_BlitSurface(image5, NULL, screen, &dest5);
SDL_BlitSurface(image7, NULL, screen, &dest7);
SDL_BlitSurface(image6, NULL, screen, &dest6);
SDL_BlitSurface(image9, NULL, screen, &dest14);
SDL_BlitSurface(image10, NULL, screen, &dest2);
SDL_BlitSurface(image14, NULL, screen, &dest16);
SDL_BlitSurface(image12, NULL, screen, &dest15);
SDL_BlitSurface(image8, NULL, screen, &dest7);
SDL_BlitSurface(image13, NULL, screen, &dest13);
SDL_BlitSurface(image6, NULL, screen, &dest6);
SDL_BlitSurface(image2, NULL, screen, &dest8);
//Flip the backbuffer to the primary Hardware Video Memory
//SDL_Flip(screen);
 int positionBallActuel;
 int positionBallPrecedente, d, k, df;
 d=0;
positionBallActuel = SDL_GetTicks();
positionBallPrecedente = 0;
while (SDL_PollEvent(&event))
{
// check for messages
switch (event.type)
{
// exit if the window is closed
// check for keypresses
case SDL_KEYDOWN:
{
// exit if ESCAPE is pressed
if ((event.key.keysym.sym == SDLK_RETURN) && (x==0))
   {if (dest8.y == 270)
    {dest7 = dest1;
    dest13 = dest5;
    dest6 = dest4;
s1=0;
s2=0;
 temp6 = SDL_LoadBMP("img/initial.bmp"); //dest6
 image6 = SDL_DisplayFormat(temp6);
 temp13 = SDL_LoadBMP("img/initial1.bmp"); //dest13
 image13 = SDL_DisplayFormat(temp13);
 temp8 = SDL_LoadBMP("img/table231.bmp"); //dest7
 image8 = SDL_DisplayFormat(temp8);
 temp10 = SDL_LoadBMP("img/score.bmp"); //dest14
 image10 = SDL_DisplayFormat(temp10);
 temp9 = SDL_LoadBMP("img/tile.bmp"); //dest
 image9 = SDL_DisplayFormat(temp9);
 SDL_SetColorKey(image2, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image2->format, 255, 255, 255));
 SDL_SetColorKey(image6, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image6->format, 255, 255, 255));
 SDL_SetColorKey(image8, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image8->format, 255, 255, 255));
 SDL_SetColorKey(image10, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image10->format, 255, 255, 255));
 SDL_SetColorKey(image13, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image13->format, 255, 255, 255));
 SDL_SetColorKey(image12, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image12->format, 0, 0, 0));
 SDL_SetColorKey(image14, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image14->format, 0, 0, 0));
x=1;}
 else if (dest8.y == 358)
{
dest8 = dest9;
temp6 = SDL_LoadBMP("img/diff.bmp");
 image6 = SDL_DisplayFormat(temp6);
 temp2 = SDL_LoadBMP("img/ball5.bmp");
 image2 = SDL_DisplayFormat(temp2);
 SDL_SetColorKey(image2, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image2->format, 255, 255, 255));
 SDL_SetColorKey(image6, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image6->format, 255, 255, 255));
 x=2;}
 else if (dest8.y == 446)
{dest8 = dest14;
    temp2 = SDL_LoadBMP("img/credit.bmp");
 image2 = SDL_DisplayFormat(temp2);
 SDL_SetColorKey(image6, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image6->format, 255, 255, 255));
 x=3;}
 else if (dest8.y == 534)
{dest8 = dest14;
 temp2 = SDL_LoadBMP("img/aide.bmp");
 image2 = SDL_DisplayFormat(temp2);
 SDL_SetColorKey(image6, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image6->format, 255, 255, 255));
 x=4;}
 else if (dest8.y == 622)
    done = 0;}
else if ((event.key.keysym.sym == SDLK_ESCAPE) && (x==1))
{{dest6 = dest14;
dest8 = dest12;
temp2 = SDL_LoadBMP("img/ball5.bmp");
 image2 = SDL_DisplayFormat(temp2);
 temp6 = SDL_LoadBMP("img/pause.bmp");
 image6 = SDL_DisplayFormat(temp6);
 SDL_SetColorKey(image2, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image2->format, 255, 255, 255));
 SDL_SetColorKey(image6, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image6->format, 255, 255, 255));
 x=11;}}
else if ((event.key.keysym.sym == SDLK_RETURN) && (x==11) && (dest8.y == 202))
{dest7 = dest1;
    dest13 = dest5;
    dest6 = dest4;
    dest8.x = 850;
    dest8.y = 300;
 temp6 = SDL_LoadBMP("img/initial.bmp"); //dest6
 image6 = SDL_DisplayFormat(temp6);
 temp13 = SDL_LoadBMP("img/initial1.bmp"); //dest13
 image13 = SDL_DisplayFormat(temp13);
 temp8 = SDL_LoadBMP("img/table231.bmp"); //dest7
 image8 = SDL_DisplayFormat(temp8);
 temp10 = SDL_LoadBMP("img/score.bmp"); //dest14
 image10 = SDL_DisplayFormat(temp10);
 temp9 = SDL_LoadBMP("img/tile.bmp"); //dest
 image9 = SDL_DisplayFormat(temp9);

 SDL_SetColorKey(image2, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image2->format, 255, 255, 255));
 SDL_SetColorKey(image6, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image6->format, 255, 255, 255));
 SDL_SetColorKey(image8, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image8->format, 255, 255, 255));
 SDL_SetColorKey(image10, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image10->format, 255, 255, 255));
 SDL_SetColorKey(image13, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image13->format, 255, 255, 255));
 SDL_SetColorKey(image12, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image12->format, 0, 0, 0));
 SDL_SetColorKey(image14, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image14->format, 0, 0, 0));
x=1;}
else if (((event.key.keysym.sym == SDLK_RETURN) && (x==11) && (dest8.y == 302)) || ((event.key.keysym.sym == SDLK_ESCAPE) && ((x == 3) || (x == 4))))
{dest8.x = 752;
dest8.y = 270;
 temp2 = SDL_LoadBMP("img/ball5.bmp");
 image2 = SDL_DisplayFormat(temp2);
 temp6 = SDL_LoadBMP("img/acceil.bmp");
 image6 = SDL_DisplayFormat(temp6);
 SDL_SetColorKey(image2, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image2->format, 255, 255, 255));
x=0;}
else if ((event.key.keysym.sym == SDLK_RETURN) && (x==11) && (dest8.y == 402))
{done = 0;}
else if ((event.key.keysym.sym == SDLK_ESCAPE) && ((x == 3) || (x == 4)))
{temp6 = SDL_LoadBMP("img/acceil.bmp");
 image6 = SDL_DisplayFormat(temp6);
 temp2 = SDL_LoadBMP("img/ball5.bmp");
 image2 = SDL_DisplayFormat(temp2);
 SDL_SetColorKey(image2, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image2->format, 255, 255, 255));
 SDL_SetColorKey(image6, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image6->format, 255, 255, 255));
 x=0;}
else if (x == 0)
{if (event.key.keysym.sym == SDLK_DOWN)
   {if ((dest8.y >= 270) && (dest8.y < 622))
 dest8.y = dest8.y + 88;}
 if (event.key.keysym.sym == SDLK_UP)
   {if ((dest8.y > 270) && (dest8.y <= 622))
 dest8.y = dest8.y - 88;}}
//else =======================================================
else if (x == 11)
{if (event.key.keysym.sym == SDLK_DOWN)
   {if ((dest8.y >= 202) && (dest8.y < 402))
 dest8.y = dest8.y + 100;}
 if (event.key.keysym.sym == SDLK_UP)
   {if ((dest8.y > 202) && (dest8.y <= 402))
 dest8.y = dest8.y - 100;}}
else if (x == 2)
 {if ((event.key.keysym.sym == SDLK_UP) && (dest8.y > 252) && (dest8.y <= 404))
 {dest8.y = dest8.y - 76;}
 else if ((event.key.keysym.sym == SDLK_DOWN) && (dest8.y >= 252) && (dest8.y < 404))
 {dest8.y = dest8.y + 76;}

 else if ((dest8.y == 252) && (event.key.keysym.sym == SDLK_RETURN))
{
    dest7 = dest1;
    dest13 = dest5;
    dest6 = dest4;
    s1=0; s2=0;
 temp6 = SDL_LoadBMP("img/initial.bmp"); //dest6
 image6 = SDL_DisplayFormat(temp6);
 temp13 = SDL_LoadBMP("img/initial1.bmp"); //dest13
 image13 = SDL_DisplayFormat(temp13);
 temp8 = SDL_LoadBMP("img/table231.bmp"); //dest7
 image8 = SDL_DisplayFormat(temp8);

temp10 = SDL_LoadBMP("img/score.bmp"); //dest14
 image10 = SDL_DisplayFormat(temp10);
 temp9 = SDL_LoadBMP("img/tile.bmp"); //dest
 image9 = SDL_DisplayFormat(temp9);

 SDL_SetColorKey(image2, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image2->format, 255, 255, 255));
 SDL_SetColorKey(image6, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image6->format, 255, 255, 255));
 SDL_SetColorKey(image8, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image8->format, 255, 255, 255));
 SDL_SetColorKey(image10, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image10->format, 255, 255, 255));
 SDL_SetColorKey(image13, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image13->format, 255, 255, 255));
 SDL_SetColorKey(image12, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image12->format, 0, 0, 0));
 SDL_SetColorKey(image14, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image14->format, 0, 0, 0));
x=1;
df=1;}
else if ((dest8.y == 328) && (event.key.keysym.sym == SDLK_RETURN))
{
  dest7 = dest1;
    dest13 = dest5;
    dest6 = dest4;
s1=0; s2=0;
 temp6 = SDL_LoadBMP("img/initial.bmp"); //dest6
 image6 = SDL_DisplayFormat(temp6);
 temp13 = SDL_LoadBMP("img/initial1.bmp"); //dest13
 image13 = SDL_DisplayFormat(temp13);
 temp8 = SDL_LoadBMP("img/table231.bmp"); //dest7
 image8 = SDL_DisplayFormat(temp8);

 temp10 = SDL_LoadBMP("img/score.bmp"); //dest14
 image10 = SDL_DisplayFormat(temp10);
 temp9 = SDL_LoadBMP("img/tile.bmp"); //dest
 image9 = SDL_DisplayFormat(temp9);

 SDL_SetColorKey(image2, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image2->format, 255, 255, 255));
 SDL_SetColorKey(image6, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image6->format, 255, 255, 255));
 SDL_SetColorKey(image8, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image8->format, 255, 255, 255));
 SDL_SetColorKey(image10, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image10->format, 255, 255, 255));
 SDL_SetColorKey(image13, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image13->format, 255, 255, 255));
 SDL_SetColorKey(image12, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image12->format, 0, 0, 0));
 SDL_SetColorKey(image14, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image14->format, 0, 0, 0));
x=1;df=2;}
else if ((dest8.y == 404) && (event.key.keysym.sym == SDLK_RETURN))
{
  dest7 = dest1;
    dest13 = dest5;
    dest6 = dest4;
    s2=0; s1=0;
 temp6 = SDL_LoadBMP("img/initial.bmp"); //dest6
 image6 = SDL_DisplayFormat(temp6);
 temp13 = SDL_LoadBMP("img/initial1.bmp"); //dest13
 image13 = SDL_DisplayFormat(temp13);
 temp8 = SDL_LoadBMP("img/table231.bmp"); //dest7
 image8 = SDL_DisplayFormat(temp8);

 temp10 = SDL_LoadBMP("img/score.bmp"); //dest14
 image10 = SDL_DisplayFormat(temp10);
 temp9 = SDL_LoadBMP("img/tile.bmp"); //dest
 image9 = SDL_DisplayFormat(temp9);

 SDL_SetColorKey(image2, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image2->format, 255, 255, 255));
 SDL_SetColorKey(image6, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image6->format, 255, 255, 255));
 SDL_SetColorKey(image8, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image8->format, 255, 255, 255));
 SDL_SetColorKey(image10, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image10->format, 255, 255, 255));
 SDL_SetColorKey(image13, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image13->format, 255, 255, 255));
 SDL_SetColorKey(image12, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image12->format, 0, 0, 0));
 SDL_SetColorKey(image14, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image14->format, 0, 0, 0));
x=1;df=3;}}

else if (x == 1){
    if (event.key.keysym.sym == SDLK_DOWN)
    {dest6.y = dest6.y + 20;}
   else if (event.key.keysym.sym == SDLK_UP)
 {dest6.y = dest6.y - 20;}
 else if (event.key.keysym.sym == SDLK_w)
 {dest13.y = dest13.y - 20;}
      else if (event.key.keysym.sym == SDLK_s)
 {dest13.y = dest13.y + 20;}
}
break; // end switch
} // end of message processing
}}
if (x == 1)

{if (df == 1)
{if(positionBallActuel - positionBallPrecedente > 1000)
    {SDL_Delay(18);
{dest8.x = dest8.x - vx;
dest8.y = dest8.y + vy;}
if ( dest8.x >= dest6.x && dest8.x < dest6.x + 10 && dest8.y > dest6.y + 5 && dest8.y <= dest6.y + 30)
        {vx = - vx;
        vy = - abs(vy);}
else if ( dest8.x > dest6.x && dest8.x < dest6.x + 10 && dest8.y > dest6.y + 30 && dest8.y <= dest6.y + 60)
        {vx = -vx;
        vy = abs(vy);}
else if( dest8.x < dest13.x + 125 && dest8.x > dest13.x + 110 && dest8.y > dest13.y + 155 && dest8.y <= dest13.y + 185)
        {vx = -vx;
        vy = - abs(vy); }
else if( dest8.x < dest13.x + 125 && dest8.x > dest13.x + 110 && dest8.y > dest13.y + 185 && dest8.y <= dest13.y + 215)
        {vx = -vx;
        vy = abs(vy);}


if ((dest8.x < 50) || (dest8.y > 700 && dest8.x > 500))
{dest8.x = 843;
dest8.y = 220;
dest6.x = 850;
dest6.y = 200;
dest13.x = 80;
dest13.y = 350;
vx = abs(vx);
vy = abs(vy);
s2=s2+1;
}
else if ((dest8.x > 1050) || (dest8.y < 100 && dest8.x < 400))
{dest8.x = 843;
dest8.y = 220;
dest6.x = 850;
dest6.y = 200;
dest13.x = 80;
dest13.y = 350;
vx = abs(vx);
vy = abs(vy);
s1=s1+1;
}
if ((s1 == 0) || (s1 == 9) || (s2 == 9)) {temp12 = SDL_LoadBMP("img/0.bmp"); //dest
 image12 = SDL_DisplayFormat(temp12);
 SDL_SetColorKey(image12, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image12->format, 0, 0, 0));}
if ((s1 == 0) || (s1 == 9) || (s2 == 9)) {temp14 = SDL_LoadBMP("img/0.bmp"); //dest
 image14 = SDL_DisplayFormat(temp14);
 SDL_SetColorKey(image14, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image14->format, 0, 0, 0));}
if (s1 == 1) {temp12 = SDL_LoadBMP("img/1.bmp"); //dest
 image12 = SDL_DisplayFormat(temp12);
 SDL_SetColorKey(image12, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image12->format, 0, 0, 0));}
if (s2 == 1) {temp14 = SDL_LoadBMP("img/1.bmp"); //dest
 image14 = SDL_DisplayFormat(temp14);
 SDL_SetColorKey(image14, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image14->format, 0, 0, 0));}
if (s1 == 2) {temp12 = SDL_LoadBMP("img/2.bmp"); //dest
 image12 = SDL_DisplayFormat(temp12);
 SDL_SetColorKey(image12, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image12->format, 0, 0, 0));}
if (s2 == 2) {temp14 = SDL_LoadBMP("img/2.bmp"); //dest
 image14 = SDL_DisplayFormat(temp14);
 SDL_SetColorKey(image14, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image14->format, 0, 0, 0));}
if (s1 == 3) {temp12 = SDL_LoadBMP("img/3.bmp"); //dest
 image12 = SDL_DisplayFormat(temp12);
 SDL_SetColorKey(image12, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image12->format, 0, 0, 0));}
if (s2 == 3) {temp14 = SDL_LoadBMP("img/3.bmp"); //dest
 image14 = SDL_DisplayFormat(temp14);
 SDL_SetColorKey(image14, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image14->format, 0, 0, 0));}
if (s1 == 4) {temp12 = SDL_LoadBMP("img/4.bmp"); //dest
 image12 = SDL_DisplayFormat(temp12);
 SDL_SetColorKey(image12, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image12->format, 0, 0, 0));}
if (s2 == 4) {temp14 = SDL_LoadBMP("img/4.bmp"); //dest
 image14 = SDL_DisplayFormat(temp14);
 SDL_SetColorKey(image14, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image14->format, 0, 0, 0));}
if (s1 == 5) {temp12 = SDL_LoadBMP("img/5.bmp"); //dest
 image12 = SDL_DisplayFormat(temp12);
 SDL_SetColorKey(image12, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image12->format, 0, 0, 0));}
if (s2 == 5) {temp14 = SDL_LoadBMP("img/5.bmp"); //dest
 image14 = SDL_DisplayFormat(temp14);
 SDL_SetColorKey(image14, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image14->format, 0, 0, 0));}
if (s1 == 6) {temp12 = SDL_LoadBMP("img/6.bmp"); //dest
 image12 = SDL_DisplayFormat(temp12);
 SDL_SetColorKey(image12, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image12->format, 0, 0, 0));}
if (s2 == 6) {temp14 = SDL_LoadBMP("img/6.bmp"); //dest
 image14 = SDL_DisplayFormat(temp14);
 SDL_SetColorKey(image14, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image14->format, 0, 0, 0));}
if (s1 == 7) {temp12 = SDL_LoadBMP("img/7.bmp"); //dest
 image12 = SDL_DisplayFormat(temp12);
 SDL_SetColorKey(image12, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image12->format, 0, 0, 0));}
if (s2 == 7) {temp14 = SDL_LoadBMP("img/7.bmp"); //dest
 image14 = SDL_DisplayFormat(temp14);
 SDL_SetColorKey(image14, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image14->format, 0, 0, 0));}
if (s1 == 8) {temp12 = SDL_LoadBMP("img/8.bmp"); //dest
 image12 = SDL_DisplayFormat(temp12);
 SDL_SetColorKey(image12, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image12->format, 0, 0, 0));}
if (s2 == 8) {temp14 = SDL_LoadBMP("img/8.bmp"); //dest
 image14 = SDL_DisplayFormat(temp14);
 SDL_SetColorKey(image14, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image14->format, 0, 0, 0));}
if (s1 == 9) {temp12 = SDL_LoadBMP("img/9.bmp"); //dest
 image12 = SDL_DisplayFormat(temp12);
 SDL_SetColorKey(image12, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image12->format, 0, 0, 0));}
if (s2 == 9) {temp14 = SDL_LoadBMP("img/9.bmp"); //dest
 image14 = SDL_DisplayFormat(temp14);
 SDL_SetColorKey(image14, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image14->format, 0, 0, 0));}




    positionBallPrecedente = positionBallActuel;}}

else if (df == 2)
    {if(positionBallActuel - positionBallPrecedente > 1000)
    {SDL_Delay(13);
{dest8.x = dest8.x - vx;
dest8.y = dest8.y + vy;}
if ( dest8.x >= dest6.x && dest8.x < dest6.x + 10 && dest8.y > dest6.y + 5 && dest8.y <= dest6.y + 30)
        {vx = - vx;
        vy = - abs(vy);}
else if ( dest8.x > dest6.x && dest8.x < dest6.x + 10 && dest8.y > dest6.y + 30 && dest8.y <= dest6.y + 60)
        {vx = -vx;
        vy = abs(vy);}
else if( dest8.x < dest13.x + 125 && dest8.x > dest13.x + 110 && dest8.y > dest13.y + 155 && dest8.y <= dest13.y + 185)
        {vx = -vx;
        vy = - abs(vy); }
else if( dest8.x < dest13.x + 125 && dest8.x > dest13.x + 110 && dest8.y > dest13.y + 185 && dest8.y <= dest13.y + 215)
        {vx = -vx;
        vy = abs(vy);}



if ((dest8.x < 50) || (dest8.y > 700 && dest8.x > 500))
{dest8.x = 843;
dest8.y = 220;
dest6.x = 850;
dest6.y = 200;
dest13.x = 80;
dest13.y = 350;
vx = abs(vx);
vy = abs(vy);
s2=s2+1;
}
else if ((dest8.x > 1050) || (dest8.y < 100 && dest8.x < 400))
{dest8.x = 843;
dest8.y = 220;
dest6.x = 850;
dest6.y = 200;
dest13.x = 80;
dest13.y = 350;
vx = abs(vx);
vy = abs(vy);
s1=s1+1;
}
if ((s1 == 0) || (s1 == 9) || (s2 == 9)) {temp12 = SDL_LoadBMP("img/0.bmp"); //dest
 image12 = SDL_DisplayFormat(temp12);
 SDL_SetColorKey(image12, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image12->format, 0, 0, 0));}
if ((s1 == 0) || (s1 == 9) || (s2 == 9)) {temp14 = SDL_LoadBMP("img/0.bmp"); //dest
 image14 = SDL_DisplayFormat(temp14);
 SDL_SetColorKey(image14, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image14->format, 0, 0, 0));}
if (s1 == 1) {temp12 = SDL_LoadBMP("img/1.bmp"); //dest
 image12 = SDL_DisplayFormat(temp12);
 SDL_SetColorKey(image12, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image12->format, 0, 0, 0));}
if (s2 == 1) {temp14 = SDL_LoadBMP("img/1.bmp"); //dest
 image14 = SDL_DisplayFormat(temp14);
 SDL_SetColorKey(image14, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image14->format, 0, 0, 0));}
if (s1 == 2) {temp12 = SDL_LoadBMP("img/2.bmp"); //dest
 image12 = SDL_DisplayFormat(temp12);
 SDL_SetColorKey(image12, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image12->format, 0, 0, 0));}
if (s2 == 2) {temp14 = SDL_LoadBMP("img/2.bmp"); //dest
 image14 = SDL_DisplayFormat(temp14);
 SDL_SetColorKey(image14, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image14->format, 0, 0, 0));}
if (s1 == 3) {temp12 = SDL_LoadBMP("img/3.bmp"); //dest
 image12 = SDL_DisplayFormat(temp12);
 SDL_SetColorKey(image12, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image12->format, 0, 0, 0));}
if (s2 == 3) {temp14 = SDL_LoadBMP("img/3.bmp"); //dest
 image14 = SDL_DisplayFormat(temp14);
 SDL_SetColorKey(image14, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image14->format, 0, 0, 0));}
if (s1 == 4) {temp12 = SDL_LoadBMP("img/4.bmp"); //dest
 image12 = SDL_DisplayFormat(temp12);
 SDL_SetColorKey(image12, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image12->format, 0, 0, 0));}
if (s2 == 4) {temp14 = SDL_LoadBMP("img/4.bmp"); //dest
 image14 = SDL_DisplayFormat(temp14);
 SDL_SetColorKey(image14, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image14->format, 0, 0, 0));}
if (s1 == 5) {temp12 = SDL_LoadBMP("img/5.bmp"); //dest
 image12 = SDL_DisplayFormat(temp12);
 SDL_SetColorKey(image12, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image12->format, 0, 0, 0));}
if (s2 == 5) {temp14 = SDL_LoadBMP("img/5.bmp"); //dest
 image14 = SDL_DisplayFormat(temp14);
 SDL_SetColorKey(image14, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image14->format, 0, 0, 0));}
if (s1 == 6) {temp12 = SDL_LoadBMP("img/6.bmp"); //dest
 image12 = SDL_DisplayFormat(temp12);
 SDL_SetColorKey(image12, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image12->format, 0, 0, 0));}
if (s2 == 6) {temp14 = SDL_LoadBMP("img/6.bmp"); //dest
 image14 = SDL_DisplayFormat(temp14);
 SDL_SetColorKey(image14, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image14->format, 0, 0, 0));}
if (s1 == 7) {temp12 = SDL_LoadBMP("img/7.bmp"); //dest
 image12 = SDL_DisplayFormat(temp12);
 SDL_SetColorKey(image12, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image12->format, 0, 0, 0));}
if (s2 == 7) {temp14 = SDL_LoadBMP("img/7.bmp"); //dest
 image14 = SDL_DisplayFormat(temp14);
 SDL_SetColorKey(image14, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image14->format, 0, 0, 0));}
if (s1 == 8) {temp12 = SDL_LoadBMP("img/8.bmp"); //dest
 image12 = SDL_DisplayFormat(temp12);
 SDL_SetColorKey(image12, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image12->format, 0, 0, 0));}
if (s2 == 8) {temp14 = SDL_LoadBMP("img/8.bmp"); //dest
 image14 = SDL_DisplayFormat(temp14);
 SDL_SetColorKey(image14, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image14->format, 0, 0, 0));}
if (s1 == 9) {temp12 = SDL_LoadBMP("img/9.bmp"); //dest
 image12 = SDL_DisplayFormat(temp12);
 SDL_SetColorKey(image12, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image12->format, 0, 0, 0));}
if (s2 == 9) {temp14 = SDL_LoadBMP("img/9.bmp"); //dest
 image14 = SDL_DisplayFormat(temp14);
 SDL_SetColorKey(image14, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image14->format, 0, 0, 0));}





    positionBallPrecedente = positionBallActuel;}}

else if (df == 3)
   {if(positionBallActuel - positionBallPrecedente > 1000)
    {SDL_Delay(8);
{dest8.x = dest8.x - vx;
dest8.y = dest8.y + vy;}
if ( dest8.x >= dest6.x && dest8.x < dest6.x + 10 && dest8.y > dest6.y + 5 && dest8.y <= dest6.y + 30)
        moveball1 (&vx,&vy);
else if ( dest8.x > dest6.x && dest8.x < dest6.x + 10 && dest8.y > dest6.y + 30 && dest8.y <= dest6.y + 60)
        {vx = -vx;
        vy = abs(vy);}
else if( dest8.x < dest13.x + 125 && dest8.x > dest13.x + 110 && dest8.y > dest13.y + 155 && dest8.y <= dest13.y + 185)
        {vx = -vx;
        vy = - abs(vy); }
else if( dest8.x < dest13.x + 125 && dest8.x > dest13.x + 110 && dest8.y > dest13.y + 185 && dest8.y <= dest13.y + 215)
        {vx = -vx;
        vy = abs(vy);}

if ((dest8.x < 50) || (dest8.y > 700 && dest8.x > 500))
{dest8.x = 843;
dest8.y = 220;
dest6.x = 850;
dest6.y = 200;
dest13.x = 80;
dest13.y = 350;
vx = abs(vx);
vy = abs(vy);
s2=s2+1;
}
else if ((dest8.x > 1050) || (dest8.y < 100 && dest8.x < 400))
{dest8.x = 843;
dest8.y = 220;
dest6.x = 850;
dest6.y = 200;
dest13.x = 80;
dest13.y = 350;
vx = abs(vx);
vy = abs(vy);
s1=s1+1;
}
if ((s1 == 0) || (s1 == 9) || (s2 == 9)) {temp12 = SDL_LoadBMP("img/0.bmp"); //dest
 image12 = SDL_DisplayFormat(temp12);
 SDL_SetColorKey(image12, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image12->format, 0, 0, 0));}
if ((s1 == 0) || (s1 == 9) || (s2 == 9)) {temp14 = SDL_LoadBMP("img/0.bmp"); //dest
 image14 = SDL_DisplayFormat(temp14);
 SDL_SetColorKey(image14, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image14->format, 0, 0, 0));}
if (s1 == 1) {temp12 = SDL_LoadBMP("img/1.bmp"); //dest
 image12 = SDL_DisplayFormat(temp12);
 SDL_SetColorKey(image12, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image12->format, 0, 0, 0));}
if (s2 == 1) {temp14 = SDL_LoadBMP("img/1.bmp"); //dest
 image14 = SDL_DisplayFormat(temp14);
 SDL_SetColorKey(image14, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image14->format, 0, 0, 0));}
if (s1 == 2) {temp12 = SDL_LoadBMP("img/2.bmp"); //dest
 image12 = SDL_DisplayFormat(temp12);
 SDL_SetColorKey(image12, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image12->format, 0, 0, 0));}
if (s2 == 2) {temp14 = SDL_LoadBMP("img/2.bmp"); //dest
 image14 = SDL_DisplayFormat(temp14);
 SDL_SetColorKey(image14, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image14->format, 0, 0, 0));}
if (s1 == 3) {temp12 = SDL_LoadBMP("img/3.bmp"); //dest
 image12 = SDL_DisplayFormat(temp12);
 SDL_SetColorKey(image12, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image12->format, 0, 0, 0));}
if (s2 == 3) {temp14 = SDL_LoadBMP("img/3.bmp"); //dest
 image14 = SDL_DisplayFormat(temp14);
 SDL_SetColorKey(image14, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image14->format, 0, 0, 0));}
if (s1 == 4) {temp12 = SDL_LoadBMP("img/4.bmp"); //dest
 image12 = SDL_DisplayFormat(temp12);
 SDL_SetColorKey(image12, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image12->format, 0, 0, 0));}
if (s2 == 4) {temp14 = SDL_LoadBMP("img/4.bmp"); //dest
 image14 = SDL_DisplayFormat(temp14);
 SDL_SetColorKey(image14, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image14->format, 0, 0, 0));}
if (s1 == 5) {temp12 = SDL_LoadBMP("img/5.bmp"); //dest
 image12 = SDL_DisplayFormat(temp12);
 SDL_SetColorKey(image12, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image12->format, 0, 0, 0));}
if (s2 == 5) {temp14 = SDL_LoadBMP("img/5.bmp"); //dest
 image14 = SDL_DisplayFormat(temp14);
 SDL_SetColorKey(image14, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image14->format, 0, 0, 0));}
if (s1 == 6) {temp12 = SDL_LoadBMP("img/6.bmp"); //dest
 image12 = SDL_DisplayFormat(temp12);
 SDL_SetColorKey(image12, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image12->format, 0, 0, 0));}
if (s2 == 6) {temp14 = SDL_LoadBMP("img/6.bmp"); //dest
 image14 = SDL_DisplayFormat(temp14);
 SDL_SetColorKey(image14, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image14->format, 0, 0, 0));}
if (s1 == 7) {temp12 = SDL_LoadBMP("img/7.bmp"); //dest
 image12 = SDL_DisplayFormat(temp12);
 SDL_SetColorKey(image12, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image12->format, 0, 0, 0));}
if (s2 == 7) {temp14 = SDL_LoadBMP("img/7.bmp"); //dest
 image14 = SDL_DisplayFormat(temp14);
 SDL_SetColorKey(image14, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image14->format, 0, 0, 0));}
if (s1 == 8) {temp12 = SDL_LoadBMP("img/8.bmp"); //dest
 image12 = SDL_DisplayFormat(temp12);
 SDL_SetColorKey(image12, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image12->format, 0, 0, 0));}
if (s2 == 8) {temp14 = SDL_LoadBMP("img/8.bmp"); //dest
 image14 = SDL_DisplayFormat(temp14);
 SDL_SetColorKey(image14, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image14->format, 0, 0, 0));}
if (s1 == 9) {temp12 = SDL_LoadBMP("img/9.bmp"); //dest
 image12 = SDL_DisplayFormat(temp12);
 SDL_SetColorKey(image12, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image12->format, 0, 0, 0));}
if (s2 == 9) {temp14 = SDL_LoadBMP("img/9.bmp"); //dest
 image14 = SDL_DisplayFormat(temp14);
 SDL_SetColorKey(image14, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image14->format, 0, 0, 0));}



    positionBallPrecedente = positionBallActuel;}}

    if (x == 1)
   {if(positionBallActuel - positionBallPrecedente > 1000)
    {SDL_Delay(13);
{dest8.x = dest8.x - vx;
dest8.y = dest8.y + vy;}
if ( dest8.x >= dest6.x && dest8.x < dest6.x + 10 && dest8.y > dest6.y + 5 && dest8.y <= dest6.y + 30)
        moveball1 (&vx, &vy);
else if ( dest8.x > dest6.x && dest8.x < dest6.x + 10 && dest8.y > dest6.y + 30 && dest8.y <= dest6.y + 60)
        moveball2 (&vx, &vy);
else if( dest8.x < dest13.x + 125 && dest8.x > dest13.x + 110 && dest8.y > dest13.y + 155 && dest8.y <= dest13.y + 185)
        moveball1 (&vx, &vy);
else if( dest8.x < dest13.x + 125 && dest8.x > dest13.x + 110 && dest8.y > dest13.y + 185 && dest8.y <= dest13.y + 215)
        moveball2 (&vx, &vy);
if ((dest8.x < 50) || (dest8.y > 700 && dest8.x > 500))
{dest8.x = 843;
dest8.y = 220;
dest6.x = 850;
dest6.y = 200;
dest13.x = 80;
dest13.y = 350;
vx = abs(vx);
vy = abs(vy);
s2=s2+1;
}
else if ((dest8.x > 1050) || (dest8.y < 100 && dest8.x < 400))
{dest8.x = 843;
dest8.y = 220;
dest6.x = 850;
dest6.y = 200;
dest13.x = 80;
dest13.y = 350;
vx = abs(vx);
vy = abs(vy);
s1=s1+1;
}

if (s1 == 0) {temp12 = SDL_LoadBMP("img/0.bmp"); //dest
 image12 = SDL_DisplayFormat(temp12);
 SDL_SetColorKey(image12, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image12->format, 0, 0, 0));}
if (s2 == 0) {temp14 = SDL_LoadBMP("img/0.bmp"); //dest
 image14 = SDL_DisplayFormat(temp14);
 SDL_SetColorKey(image14, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image14->format, 0, 0, 0));}


if (s1 == 1) {temp12 = SDL_LoadBMP("img/1.bmp"); //dest
 image12 = SDL_DisplayFormat(temp12);
 SDL_SetColorKey(image12, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image12->format, 0, 0, 0));}
if (s2 == 1) {temp14 = SDL_LoadBMP("img/1.bmp"); //dest
 image14 = SDL_DisplayFormat(temp14);
 SDL_SetColorKey(image14, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image14->format, 0, 0, 0));}
if (s1 == 2) {temp12 = SDL_LoadBMP("img/2.bmp"); //dest
 image12 = SDL_DisplayFormat(temp12);
 SDL_SetColorKey(image12, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image12->format, 0, 0, 0));}
if (s2 == 2) {temp14 = SDL_LoadBMP("img/2.bmp"); //dest
 image14 = SDL_DisplayFormat(temp14);
 SDL_SetColorKey(image14, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image14->format, 0, 0, 0));}
if (s1 == 3) {temp12 = SDL_LoadBMP("img/3.bmp"); //dest
 image12 = SDL_DisplayFormat(temp12);
 SDL_SetColorKey(image12, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image12->format, 0, 0, 0));}
if (s2 == 3) {temp14 = SDL_LoadBMP("img/3.bmp"); //dest
 image14 = SDL_DisplayFormat(temp14);
 SDL_SetColorKey(image14, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image14->format, 0, 0, 0));}
if (s1 == 4) {temp12 = SDL_LoadBMP("img/4.bmp"); //dest
 image12 = SDL_DisplayFormat(temp12);
 SDL_SetColorKey(image12, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image12->format, 0, 0, 0));}
if (s2 == 4) {temp14 = SDL_LoadBMP("img/4.bmp"); //dest
 image14 = SDL_DisplayFormat(temp14);
 SDL_SetColorKey(image14, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image14->format, 0, 0, 0));}
if (s1 == 5) {temp12 = SDL_LoadBMP("img/5.bmp"); //dest
 image12 = SDL_DisplayFormat(temp12);
 SDL_SetColorKey(image12, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image12->format, 0, 0, 0));}
if (s2 == 5) {temp14 = SDL_LoadBMP("img/5.bmp"); //dest
 image14 = SDL_DisplayFormat(temp14);
 SDL_SetColorKey(image14, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image14->format, 0, 0, 0));}
if (s1 == 6) {temp12 = SDL_LoadBMP("img/6.bmp"); //dest
 image12 = SDL_DisplayFormat(temp12);
 SDL_SetColorKey(image12, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image12->format, 0, 0, 0));}
if (s2 == 6) {temp14 = SDL_LoadBMP("img/6.bmp"); //dest
 image14 = SDL_DisplayFormat(temp14);
 SDL_SetColorKey(image14, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image14->format, 0, 0, 0));}
if (s1 == 7) {temp12 = SDL_LoadBMP("img/7.bmp"); //dest
 image12 = SDL_DisplayFormat(temp12);
 SDL_SetColorKey(image12, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image12->format, 0, 0, 0));}
if (s2 == 7) {temp14 = SDL_LoadBMP("img/7.bmp"); //dest
 image14 = SDL_DisplayFormat(temp14);
 SDL_SetColorKey(image14, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image14->format, 0, 0, 0));}
if (s1 == 8) {temp12 = SDL_LoadBMP("img/8.bmp"); //dest
 image12 = SDL_DisplayFormat(temp12);
 SDL_SetColorKey(image12, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image12->format, 0, 0, 0));}
if (s2 == 8) {temp14 = SDL_LoadBMP("img/8.bmp"); //dest
 image14 = SDL_DisplayFormat(temp14);
 SDL_SetColorKey(image14, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image14->format, 0, 0, 0));}
if (s1 == 9) {temp12 = SDL_LoadBMP("img/9.bmp"); //dest
 image12 = SDL_DisplayFormat(temp12);
 SDL_SetColorKey(image12, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image12->format, 0, 0, 0));}
if (s2 == 9) {temp14 = SDL_LoadBMP("img/9.bmp"); //dest
 image14 = SDL_DisplayFormat(temp14);
 SDL_SetColorKey(image14, SDL_RLEACCEL | SDL_SRCCOLORKEY, SDL_MapRGB(image14->format, 0, 0, 0));}
    positionBallPrecedente = positionBallActuel;}}
}
if((s2==10)||(s1==10))
    return 0;
SDL_BlitSurface(image2, NULL, screen, &dest8);
SDL_Flip(screen);
}
return 0;
}

void moveball1 (int *vx,int *vy){
    *vx = - *(vx);
        *vy = - abs(*vy);
}
void moveball2 (int *vx, int *vy){
    *vx = - *(vx);
        *vy = abs(*(vy));
}
